import axios from "axios";
import { Dispatch } from "redux";
import { Anyaction } from "../untils/index";
export let getlist = () => {
  return async (dispatch: Dispatch) => {
    let { data } = await axios.get("/api/list");
    dispatch({
      type: "GET_LIST",
      payload: data.list,
    });
  };
};
export let check_active = (index: number) => {
  return {
    type: "CHECK_ACTIVE",
    payload: index,
  };
};

export let login = (values: Anyaction) => {
  return async (dispatch: Dispatch) => {
    let { data } = await axios.get("/api/login", { params: values });
    dispatch({
      type: "LOGIN",
      payload: Object.assign({}, values, { ...data }),
    });
  };
};
export let reg = (values: Anyaction) => {
  return async (dispatch: Dispatch) => {
    let { data } = await axios.get("/api/reg", { params: values });
    dispatch({
        "type":"REG",
        payload: Object.assign({}, values, { ...data }),
    })
  };
};
